package it.polimi.TravelDream;

import java.io.Serializable;

import javax.persistence.*;

import java.util.Date;
import java.util.List;


/**
 * The persistent class for the basepackage database table.
 * 
 */
@Entity
@NamedQueries({
@NamedQuery(name="Basepackage.findAll", query="SELECT b FROM Basepackage b"),
@NamedQuery(name="Basepackage.searchQuery", query="SELECT b FROM Basepackage b WHERE b.depLocation LIKE :param1 and b.arrLocation LIKE :param2 and b.arrDate >= :param3")
})

public class Basepackage implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private int id;

	@Temporal(TemporalType.DATE)
	private Date arrDate;

	private String arrLocation;

	@Temporal(TemporalType.DATE)
	private Date createdDate;

	@Temporal(TemporalType.DATE)
	private Date depDate;

	private String depLocation;

	//bi-directional many-to-one association to Flight
	@ManyToOne
	@JoinColumn(name="OutFlightID")
	private Flight flight1;

	//bi-directional many-to-one association to Flight
	@ManyToOne
	@JoinColumn(name="RetFlightID")
	private Flight flight2;

	//bi-directional many-to-one association to Hotel
	@ManyToOne
	@JoinColumn(name="HotelID")
	private Hotel hotel;

	//bi-directional many-to-one association to User
	@ManyToOne
	@JoinColumn(name="CreateBy")
	private User user;
	
	//bi-directional many-to-one association to Baseackexlinker
	@OneToMany(mappedBy="basepackage", cascade=CascadeType.REMOVE)
	private List<Basepackexlinker> basepackexlinkers;

	public Basepackage() {
	}

	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public Date getArrDate() {
		return this.arrDate;
	}

	public void setArrDate(Date arrDate) {
		this.arrDate = arrDate;
	}

	public String getArrLocation() {
		return this.arrLocation;
	}

	public void setArrLocation(String arrLocation) {
		this.arrLocation = arrLocation;
	}

	public Date getCreatedDate() {
		return this.createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	public Date getDepDate() {
		return this.depDate;
	}

	public void setDepDate(Date depDate) {
		this.depDate = depDate;
	}

	public String getDepLocation() {
		return this.depLocation;
	}

	public void setDepLocation(String depLocation) {
		this.depLocation = depLocation;
	}

	public Flight getFlight1() {
		return this.flight1;
	}

	public void setFlight1(Flight flight1) {
		this.flight1 = flight1;
	}

	public Flight getFlight2() {
		return this.flight2;
	}

	public void setFlight2(Flight flight2) {
		this.flight2 = flight2;
	}

	public Hotel getHotel() {
		return this.hotel;
	}

	public void setHotel(Hotel hotel) {
		this.hotel = hotel;
	}

	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}
	
	public Basepackage(BasePackageDTO basepackage) {
//		NOT IMPLEMENTED
//		this.id = basepackage.getId();
//		this.arrDate = basepackage.getRetDate();
//		this.arrLocation = basepackage.getArrLocation();
//		this.depDate = basepackage.getDepDate();
//		this.depLocation = basepackage.getDepLocation();
////		this.flight1 = basepackage.getOutFlightID();
////		this.flight2. = basepackage.getRetFlightID();
////		this.hotel.setId(getHotel().getId());		
	}
	
	public List<Basepackexlinker> getBasepackexlinkers() {
		return this.basepackexlinkers;
	}

	public void setBasepackexlinkers(List<Basepackexlinker> basepackexlinkers) {
		this.basepackexlinkers = basepackexlinkers;
	}

	public Basepackexlinker addBasepackexlinker(Basepackexlinker basepackexlinker) {
		getBasepackexlinkers().add(basepackexlinker);
		basepackexlinker.setBasepackage(this);

		return basepackexlinker;
	}

	public Basepackexlinker removeBasepackexlinker(Basepackexlinker basepackexlinker) {
		getBasepackexlinkers().remove(basepackexlinker);
		basepackexlinker.setBasepackage(null);

		return basepackexlinker;
	}

}